package com.skyable.auth.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.skyable.auth.entity.SysPermission;
import com.skyable.auth.mapper.PermissionMapper;
import com.skyable.auth.service.IPermissionService;
import com.skyable.common.common.ServiceResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author GaoYuan
 * @title: PermissionServiceImpl
 * @projectName spring-cloud-oauth2-demo
 * @description: TODO
 * @date 2021/4/129:22
 */
@Service
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper,SysPermission> implements IPermissionService {

    @Autowired
    private PermissionMapper permissionMapper;

    @Override
    public ServiceResult<List<SysPermission>> findPermissionList() {
        ServiceResult<List<SysPermission>> serviceResult = new ServiceResult<>();
        List<SysPermission> sysPermissionList = lambdaQuery().list();
        serviceResult.setResult(sysPermissionList);
        return serviceResult;
    }

    @Override
    public ServiceResult<List<SysPermission>> findPermissionByUserName(String userName) {
        ServiceResult<List<SysPermission>> serviceResult = new ServiceResult<>();
        List<SysPermission> sysPermissionList = permissionMapper.findPermissionByUserName(userName);
        serviceResult.setResult(sysPermissionList);
        return serviceResult;
    }
}
